Python vtk.vtkIntArray函数代码示例

您所在的位置:网站首页 array block education Python vtk.vtkIntArray函数代码示例

Python vtk.vtkIntArray函数代码示例

#Python vtk.vtkIntArray函数代码示例| 来源: 网络整理| 查看: 265

本文整理汇总了Python中vtk.vtkIntArray函数的典型用法代码示例。如果您正苦于以下问题:Python vtkIntArray函数的具体用法?Python vtkIntArray怎么用?Python vtkIntArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vtkIntArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__ def __init__(self, filename, max_num_of_vertices=-1, edge_color_filename=None): super(VTKVisualizer, self).__init__() self.vertex_id_idx_map = {} self.next_vertex_id = 0 self.edge_counter = 0 self.lookup_table = vtk.vtkLookupTable() self.lookup_table.SetNumberOfColors(int(1e8)) self.edge_color_tuples = {} self.edge_color_filename = edge_color_filename self.label_vertex_id_map = {} self.starting_vertex = None self.starting_vertex_index = -1 self.filename = filename self.max_num_of_vertices = max_num_of_vertices self.g = vtk.vtkMutableDirectedGraph() self.vertex_ids = vtk.vtkIntArray() self.vertex_ids.SetNumberOfComponents(1) self.vertex_ids.SetName(VERTEX_ID) self.labels = vtk.vtkStringArray() self.labels.SetNumberOfComponents(1) self.labels.SetName(LABELS) self.glyph_scales = vtk.vtkFloatArray() self.glyph_scales.SetNumberOfComponents(1) self.glyph_scales.SetName(SCALES) self.edge_weights = vtk.vtkDoubleArray() self.edge_weights.SetNumberOfComponents(1) self.edge_weights.SetName(WEIGHTS) self.edge_colors = vtk.vtkIntArray() self.edge_colors.SetNumberOfComponents(1) self.edge_colors.SetName(EDGE_COLORS)开发者ID:AlexLeSang,项目名称:NetGraph,代码行数:35,代码来源:vtkVisualizeGraph.py 示例2: testBarGraph def testBarGraph(self): "Test if bar graphs can be built with python" # Set up a 2D scene, add an XY chart to it view = vtk.vtkContextView() view.GetRenderer().SetBackground(1.0,1.0,1.0) view.GetRenderWindow().SetSize(400,300) chart = vtk.vtkChartXY() view.GetScene().AddItem(chart) # Create a table with some points in it table = vtk.vtkTable() arrMonth = vtk.vtkIntArray() arrMonth.SetName("Month") arr2008 = vtk.vtkIntArray() arr2008.SetName("2008") arr2009 = vtk.vtkIntArray() arr2009.SetName("2009") arr2010 = vtk.vtkIntArray() arr2010.SetName("2010") numMonths = 12 for i in range(0,numMonths): arrMonth.InsertNextValue(i + 1) arr2008.InsertNextValue(data_2008[i]) arr2009.InsertNextValue(data_2009[i]) arr2010.InsertNextValue(data_2010[i]) table.AddColumn(arrMonth) table.AddColumn(arr2008) table.AddColumn(arr2009) table.AddColumn(arr2010) # Now add the line plots with appropriate colors line = chart.AddPlot(2) line.SetInput(table,0,1) line.SetColor(0,255,0,255) line = chart.AddPlot(2) line.SetInput(table,0,2) line.SetColor(255,0,0,255); line = chart.AddPlot(2) line.SetInput(table,0,3) line.SetColor(0,0,255,255); view.GetRenderWindow().SetMultiSamples(0) view.GetRenderWindow().Render() img_file = "TestBarGraph.png" vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25) vtk.test.Testing.interact()开发者ID:kramarb,项目名称:VTK,代码行数:57,代码来源:TestBarGraph.py 示例3: TestDataType def TestDataType(dataType, reader, writer, ext, numTris, useSubdir=False): s = GetSource(dataType) filename = VTK_TEMP_DIR + "/%s.p%s" % (dataType, ext) writer.SetInputConnection(s.GetOutputPort()) npieces = 16 writer.SetNumberOfPieces(npieces) pperrank = npieces // nranks start = pperrank * rank end = start + pperrank - 1 writer.SetStartPiece(start) writer.SetEndPiece(end) writer.SetFileName(filename) if useSubdir: writer.SetUseSubdirectory(True) #writer.SetDataModeToAscii() writer.Write() if contr: contr.Barrier() reader.SetFileName(filename) cf = vtk.vtkContourFilter() cf.SetValue(0, 130) cf.SetComputeNormals(0) cf.SetComputeGradients(0) cf.SetInputConnection(reader.GetOutputPort()) cf.UpdateInformation() cf.GetOutputInformation(0).Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_NUMBER_OF_PIECES(), nranks) cf.GetOutputInformation(0).Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_PIECE_NUMBER(), rank) cf.Update() ntris = cf.GetOutput().GetNumberOfCells() da = vtk.vtkIntArray() da.InsertNextValue(ntris) da2 = vtk.vtkIntArray() da2.SetNumberOfTuples(1) contr.AllReduce(da, da2, vtk.vtkCommunicator.SUM_OP) if rank == 0: print(da2.GetValue(0)) import os os.remove(filename) for i in range(npieces): if not useSubdir: os.remove(VTK_TEMP_DIR + "/%s_%d.%s" % (dataType, i, ext)) else: os.remove(VTK_TEMP_DIR + "/%s/%s_%d.%s" %(dataType, dataType, i, ext)) assert da2.GetValue(0) == numTris开发者ID:inviCRO,项目名称:VTK,代码行数:53,代码来源:testParallelXMLWriters.py 示例4: loadActorsFromFile def loadActorsFromFile(self): global show_height, show_width file1 = open(self.bouttons_src) for line_i in file1: list_i = line_i.strip().split('\t') line_index = int(list_i[0]) slice_index = int(list_i[1]) x1, y1, z1 = self.lines[line_index][slice_index][2 : 5] x0 = int(x1 * 10 / 3 - show_width / 2) y0 = int(y1 * 10 / 3 - show_height / 2) x = float(list_i[2]) y = float(list_i[3]) z = float(list_i[4]) index_array = vtk.vtkIntArray() index_array.SetNumberOfComponents(1) index_array.InsertNextValue(line_index) index_array.InsertNextValue(slice_index) location_array = vtk.vtkFloatArray() location_array.SetNumberOfComponents(3) location_array.InsertNextTupleValue((x, y, z)) isNewArray = vtk.vtkIntArray() isNewArray.SetNumberOfComponents(1) isNewArray.InsertNextValue(0) index_array.SetName('Indices') location_array.SetName('Locations') isNewArray.SetName('IsNew') actor1 = MyActor() actor1.maFieldData.AddArray(index_array) actor1.maFieldData.AddArray(location_array) actor1.maFieldData.AddArray(isNewArray) actor1.GetProperty().SetColor(255.0, 0, 255.0) sphere1 = vtk.vtkSphereSource() sphere1.SetCenter(x - x0, y - y0, 0) sphere1.SetRadius(self.sphere_radius_ren1) mapper1 = vtk.vtkPolyDataMapper() mapper1.SetInputConnection(sphere1.GetOutputPort()) actor1.SetMapper(mapper1) self.ren1_sphere_actors.AddItem(actor1) matrix1 = vtk.vtkMatrix4x4() actor1.SetVisibility(False) if self.ren1AssemblyList[line_index] is None: self.ren1AssemblyList[line_index] = [None] * len(self.lines[line_index]) if self.ren1AssemblyList[line_index][slice_index] is None: assembly1 = vtk.vtkAssemblyPath() self.ren1AssemblyList[line_index][slice_index] = assembly1 self.ren1AssemblyList[line_index][slice_index].AddNode(actor1, matrix1) self.ren1.AddActor(actor1) file1.close()开发者ID:sulei1324,项目名称:lab_codes,代码行数:48,代码来源:test1.py 示例5: get_vtk_data def get_vtk_data(self,geo): """Returns dictionary of VTK data arrays from rock types. The geometry object geo must be passed in.""" from vtk import vtkIntArray,vtkFloatArray,vtkCharArray arrays={'Block':{'Rock type index':vtkIntArray(),'Porosity':vtkFloatArray(), 'Permeability':vtkFloatArray(),'Name':vtkCharArray()},'Node':{}} vector_properties=['Permeability'] string_properties=['Name'] string_length=5 nele=geo.num_underground_blocks array_length={'Block':nele,'Node':0} for array_type,array_dict in arrays.items(): for name,array in array_dict.items(): array.SetName(name) if name in vector_properties: array.SetNumberOfComponents(3) array.SetNumberOfTuples(array_length[array_type]) elif name in string_properties: array.SetNumberOfComponents(string_length) array.SetNumberOfTuples(array_length[array_type]) else: array.SetNumberOfComponents(1) array.SetNumberOfValues(array_length[array_type]) natm=geo.num_atmosphere_blocks rindex=self.rocktype_indices[natm:] for i,ri in enumerate(rindex): arrays['Block']['Rock type index'].SetValue(i,ri) rt=self.rocktypelist[ri] arrays['Block']['Porosity'].SetValue(i,rt.porosity) k=rt.permeability arrays['Block']['Permeability'].SetTuple3(i,k[0],k[1],k[2]) for i,blk in enumerate(self.blocklist[natm:]): arrays['Block']['Name'].SetTupleValue(i,blk.name) return arrays开发者ID:neerja007,项目名称:PyTOUGH,代码行数:33,代码来源:t2grids.py 示例6: write_vtk def write_vtk(self, DX=2.0, DY=2.0, DZ=0.05): """Reads cell data from vals array and writes into a VTK file called 'Stratal_Arch.vti' and is a structure grid object. Spacing defaults are 2.0/2.0/0.05""" vtk_obj = vtkImageData() vtk_obj.SetSpacing(DX, DY, DZ) vtk_obj.SetDimensions(self.dims[0]+1, self.dims[1]+1, self.dims[2]+1) # Start writing from the top of the object to match output from Eclipse vtk_obj.SetOrigin(0, 0, self.dims[2]+1) array = vtkIntArray() array.SetName("Stratal Architecture") array.SetNumberOfComponents(1) for z in range(0, self.dims[2]): for y in range(0, self.dims[1]): for x in range(0, self.dims[0]): val = self.vals[x][y][z] array.InsertNextTuple1(val) vtk_obj.GetCellData().AddArray(array) vtk_f = vtkXMLImageDataWriter() vtk_f.SetFileName("Stratal_Arch.vti") vtk_f.SetInputData(vtk_obj) vtk_f.Write()开发者ID:crappyoats,项目名称:indicator_read,代码行数:28,代码来源:BinaryGrid.py 示例7: ndarray_to_vtkarray def ndarray_to_vtkarray(colors, radius, nbat): # define the colours color_scalars = vtk.vtkFloatArray() color_scalars.SetNumberOfValues(colors.shape[0]) for i,c in enumerate(colors): color_scalars.SetValue(i,c) color_scalars.SetName("colors") # some radii radius_scalars = vtk.vtkFloatArray() radius_scalars.SetNumberOfValues(radius.shape[0]) for i,r in enumerate(radius): radius_scalars.SetValue(i,r) radius_scalars.SetName("radius") # the original index index_scalars = vtk.vtkIntArray() index_scalars.SetNumberOfValues(nbat) for i in range(nbat): index_scalars.SetValue(i,i) index_scalars.SetName("index") scalars = vtk.vtkFloatArray() scalars.SetNumberOfComponents(3) scalars.SetNumberOfTuples(radius_scalars.GetNumberOfTuples()) scalars.CopyComponent(0, radius_scalars ,0 ) scalars.CopyComponent(1, color_scalars ,0 ) scalars.CopyComponent(2, index_scalars ,0 ) scalars.SetName("scalars") return scalars 开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:30,代码来源:MolecularViewerPlugin.py 示例8: _format_output_polydata def _format_output_polydata(output_polydata, cluster_idx, color, embed): """ Output polydata with embedding colors, cluster numbers, and embedding coordinates. Cell data array names are: EmbeddingColor ClusterNumber EmbeddingCoordinate """ embed_colors = vtk.vtkUnsignedCharArray() embed_colors.SetNumberOfComponents(3) embed_colors.SetName('EmbeddingColor') cluster_colors = vtk.vtkIntArray() cluster_colors.SetName('ClusterNumber') embed_data = vtk.vtkFloatArray() embed_data.SetNumberOfComponents(embed.shape[1]) embed_data.SetName('EmbeddingCoordinate') for lidx in range(0, output_polydata.GetNumberOfLines()): embed_colors.InsertNextTuple3( color[lidx, 0], color[lidx, 1], color[lidx, 2]) cluster_colors.InsertNextTuple1(int(cluster_idx[lidx])) embed_data.InsertNextTupleValue(embed[lidx, :]) output_polydata.GetCellData().AddArray(embed_data) output_polydata.GetCellData().AddArray(cluster_colors) output_polydata.GetCellData().AddArray(embed_colors) output_polydata.GetCellData().SetActiveScalars('EmbeddingColor') return output_polydata开发者ID:baothien,项目名称:tiensy,代码行数:33,代码来源:cluster.py 示例9: export2vts def export2vts(self, filename): import vtk grid = self.info['grid'] # Set grid points points = vtk.vtkPoints() for z in range (grid[2]): for y in range (grid[1]): for x in range (grid[0]): points.InsertNextPoint( [x , y , z ] ) struGrid = vtk.vtkStructuredGrid() struGrid.SetDimensions( grid ) struGrid.SetPoints( points ) struGrid.Update() # Set point data grid_pt_num = struGrid.GetNumberOfPoints() array = vtk.vtkIntArray() array.SetNumberOfComponents(1) # this is 3 for a vector array.SetNumberOfTuples(grid_pt_num) array.SetName('MicrostructureID') matPoint = self.microstructure.reshape( [grid_pt_num] ) for i in range(grid_pt_num): array.SetValue(i, matPoint[i]) struGrid.GetPointData().AddArray(array) struGrid.Update() # Write output file outWriter = vtk.vtkXMLStructuredGridWriter() outWriter.SetDataModeToBinary() outWriter.SetCompressorTypeToZLib() outWriter.SetFileName( filename + '.vts' ) outWriter.SetInput(struGrid) outWriter.Update() outWriter.Write()开发者ID:gdlmx,项目名称:DAMASK_GUI,代码行数:32,代码来源:GeomFile.py 示例10: testObjectConstructor def testObjectConstructor(self): """Construct from VTK object""" o = vtk.vtkIntArray() v = vtk.vtkVariant(o) self.assertEqual(v.GetType(), vtk.VTK_OBJECT) self.assertEqual(v.GetTypeAsString(), o.GetClassName()) self.assertEqual(v.ToVTKObject(), o)开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:TestVariant.py 示例11: vtkIntArray def vtkIntArray(it): """Makes a vtkIntArray from a Python iterable""" via = vtk.vtkIntArray() via.SetNumberOfTuples(len(it)) for idx,val in enumerate(it): via.SetValue(idx, int(val)) return via开发者ID:EmmetCaulfield,项目名称:miscellany,代码行数:7,代码来源:__init__.py 示例12: createTrail def createTrail(ts): Points = vtk.vtkPoints() id_array = vtk.vtkIntArray() #id_array.SetNumberofComponents(1) id_array.SetName("haloid") phi_array = vtk.vtkDoubleArray() phi_array.SetName("phi") for i in range(0,ts+1): px,py,pz,phid,pphi = readParticle(i) for j in range(0,len(px)): Points.InsertNextPoint(px[j],py[j],pz[j]) id_array.InsertNextTuple1(phid[j]) phi_array.InsertNextTuple1(pphi[j]) polydata = vtk.vtkPolyData() polydata.SetPoints(Points) polydata.GetPointData().AddArray(id_array) polydata.GetPointData().AddArray(phi_array) if vtk.VTK_MAJOR_VERSION


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3